package scenic.path;

import java.awt.Rectangle;

import scenic.geom.Affine2;
import scenic.geom.Double2;

/**
 * This class defines a straight line segment. This class does not 
 * define the start point of the line. The start point is the 
 * end point of the previous segment.
 */
public class LineSegment implements Segment {
	private double x;
	private double y;
	
	/**
	 * Creates a straight line segment with the given parameters.
	 * 
	 * @param x the x coordinate of the end point.
	 * @param y the y coordinate of the end point.
	 */
	public LineSegment(double x, double y) {
		this.x = x;
		this.y = y;
	}
	
	/**
	 * Gets the x coordinate of the end point.
	 */
	public double getX() {
		return x;
	}

	/**
	 * Gets the y coordinate of the end point.
	 */
	public double getY() {
		return y;
	}

	public void walk(PathWalker walker, Double2 position, Affine2 error) {
		walker.lineTo(x, y);
		position.x = x;
		position.y = y;
	}
	
	public void getBounds(Affine2 transform, Rectangle r, Double2 position) {
		Path.addPointToBounds(transform, r, x, y);
		
		position.x = x;
		position.y = y;
	}
	
}
